<template>
	<div class="app-container">
		<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="120px">
			<el-form-item label="移位任务编码" prop="archMoveNo">
				<el-input v-model="queryParams.archMoveNo" placeholder="请输入盒间移位任务编码" clearable
					@keyup.enter="handleQuery" />
			</el-form-item>
			<el-form-item label="移位状态" prop="moveStatus">
				<el-select v-model="queryParams.moveStatus" placeholder="请选择移位状态" clearable>
					<el-option v-for="dict in shift_status" :key="dict.value" :label="dict.label" :value="dict.value" />
				</el-select>
			</el-form-item>
			<el-form-item label="盒号" prop="boxNo">
				<el-input v-model="queryParams.boxNo" placeholder="请输入盒号" clearable @keyup.enter="handleQuery" />
			</el-form-item>
			<el-form-item label="档案名称" prop="archiveName">
				<el-input v-model="queryParams.archiveName" placeholder="请输入档案名称" clearable @keyup.enter="handleQuery" />
			</el-form-item>
			<el-form-item label="档案类型" prop="archiveType">
				<el-select v-model="queryParams.archiveType" placeholder="请选择档案类型">
					<el-option v-for="dict in archive_type" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
				</el-select>
			</el-form-item>
			<el-form-item label="资料种类" prop="meansType">
				<el-select v-model="queryParams.meansType" placeholder="请选择资料种类">
					<el-option v-for="dict in means_type" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
				</el-select>
			</el-form-item>
			<el-form-item label="对象编号" prop="archObjNo">
				<el-input v-model="queryParams.archObjNo" placeholder="请输入对象编号" clearable @keyup.enter="handleQuery" />
			</el-form-item>
			<el-form-item label="对象名称" prop="archObjName">
				<el-input v-model="queryParams.archObjName" placeholder="请输入对象名称" clearable @keyup.enter="handleQuery" />
			</el-form-item>
			<el-form-item>
				<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
				<el-button icon="Refresh" @click="resetQuery">重置</el-button>
			</el-form-item>
		</el-form>

		<el-row :gutter="10" class="mb8">
			<el-col :span="1.5">
				<el-button type="warning" plain icon="Download" @click="handleExport"
					v-hasPermi="['archive:ArchiveBoxinnerMove:export']">导出</el-button>
			</el-col>
			<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
		</el-row>

		<el-table v-loading="loading" :data="ArchiveBoxinnerMoveList" @selection-change="handleSelectionChange">
			<el-table-column label="序号" align='center' width="100">
				<template #default="scope">
					{{ scope.$index+1 }}
				</template>
			</el-table-column>
			<el-table-column label="移位任务编码" align="center" prop="archMoveNo" width="150"/>
			<el-table-column label="新档案盒号" prop="newBoxNo" align="center" width="150">
			</el-table-column>
			<el-table-column label="新档案袋号" prop="newBagNo" align="center" width="150">
			</el-table-column>
			<el-table-column label="原盒盒满标志" prop="oldBoxFullStatus" align="center" width="150">
				<template #default="scope">
						<dict-tag :options="box_full_flag" :value="scope.row.oldBoxFullStatus" />
					</template>
				</el-table-column>
			<el-table-column label="新盒盒满标志" prop="newBoxFullStatus" align="center" width="150">
			<template #default="scope">
					<dict-tag :options="box_full_flag" :value="scope.row.newBoxFullStatus" />
				</template>
			</el-table-column>
			<el-table-column label="档案区编号" width="150" align="center" prop="areaNo" />
			<el-table-column label="档案柜编号" align="center" prop="cabinetNo" width="150" />
			<el-table-column label="档案盒号" align="center" prop="boxNo" width="150" />
			<el-table-column label="档案盒位置" align="center" prop="storLoc" width="300" />
			<el-table-column label="资料名称" align="center" prop="archiveName" width="330" />
			<el-table-column label="档案类型" align="center" prop="archiveType" width="150">
				<template #default="scope">
					<dict-tag :options="archive_type" :value="scope.row.archiveType" />
				</template>
			</el-table-column>
			<el-table-column label="档案密级" align="center" prop="conLevel" width="100">
				<template #default="scope">
					<dict-tag :options="confd_lv" :value="scope.row.conLevel" />
				</template>
			</el-table-column>
			<el-table-column label="保管期限" align="center" prop="saveDate" width="100">
				<template #default="scope">
					<dict-tag :options="keep_dur" :value="scope.row.saveDate" />
				</template>
			</el-table-column>
			<el-table-column label="资料种类	" align="center" prop="meansType" width="150">
				<template #default="scope">
					<dict-tag :options="means_type" :value="scope.row.meansType" />
				</template>
			</el-table-column>
			<el-table-column label="介质类型" align="center" prop="medForm">
				<template #default="scope">
					<dict-tag :options="med_form" :value="scope.row.medForm" />
				</template>
			</el-table-column>
			<el-table-column label="对象类型" align="center" prop="archObjType" width="150">
				<template #default="scope">
					<dict-tag :options="arch_obj_type" :value="scope.row.archObjType" />
				</template>
			</el-table-column>
			<el-table-column label="对象编号" align="center" prop="archObjNo" width="150" />
			<el-table-column label="对象名称" align="center" prop="archObjName" />
			
		</el-table>

		<pagination v-show="total>0" :total="total" v-model:page="queryParams.pageNum"
			v-model:limit="queryParams.pageSize" @pagination="getList" />

	</div>
</template>

<script setup name="ArchiveBoxinnerMove">
	import {
		listArchiveBoxinnerMove,
		getArchiveBoxinnerMove,
		delArchiveBoxinnerMove,
		addArchiveBoxinnerMove,
		updateArchiveBoxinnerMove
	} from "@/api/archive/ArchiveBoxinnerMove";
	import {
		getCurrentInstance,
		reactive,
		ref,
		toRefs
	} from "vue";

	const {
		proxy
	} = getCurrentInstance();
	const {
		box_full_flag,
		push_status,
		execut_result,
		shift_status,
		archive_type,
		save_extended,
		borrow_flag,
		keep_dur,
		confd_lv,
		med_form,
		means_type,
		arch_obj_type
	} = proxy.useDict('box_full_flag','push_status', 'execut_result', 'shift_status', 'archive_type', 'save_extended', 'borrow_flag',
		'keep_dur', 'confd_lv', 'med_form', 'means_type', 'arch_obj_type');
	const ArchiveBoxinnerMoveList = ref([]);
	const open = ref(false);
	const loading = ref(true);
	const showSearch = ref(true);
	const ids = ref([]);
	const single = ref(true);
	const multiple = ref(true);
	const total = ref(0);
	const title = ref("");

	const data = reactive({
		form: {},
		queryParams: {
			pageNum: 1,
			pageSize: 10,
			taskId: null,
			flowName: null,
			archNo: null,
			archName: null,
			archNum: null,
			ruleName: null,
			oldBoxNo: null,
			oldBagNo: null,
			oldHouseLocationNo: null,
			newBoxNo: null,
			newBagNo: null,
			newHouseLocationNo: null,
			oldBoxFullStatus: null,
			newBoxFullStatus: null,
			archMoveNo: null,
			boxNo: null,
			archiveType: null,
			archiveName: null,
			meansType: null,
			medForm: null,
			archObjType: null,
			archObjNo: null,
			archObjName: null,
		},
		rules: {}
	});

	const {
		queryParams,
		form,
		rules
	} = toRefs(data);

	/** 查询盒间移位详情列表 */
	function getList() {
		loading.value = true;
		listArchiveBoxinnerMove(queryParams.value).then(response => {
			ArchiveBoxinnerMoveList.value = response.rows;
			total.value = response.total;
			loading.value = false;
		});
	}

	// 取消按钮
	function cancel() {
		open.value = false;
		reset();
	}

	// 表单重置
	function reset() {
		form.value = {
			id: null,
			taskId: null,
			flowName: null,
			archNo: null,
			archName: null,
			archNum: null,
			ruleName: null,
			oldBoxNo: null,
			oldBagNo: null,
			oldHouseLocationNo: null,
			newBoxNo: null,
			newBagNo: null,
			newHouseLocationNo: null,
			oldBoxFullStatus: "0",
			newBoxFullStatus: "0",
			boxNo: null,
			archiveType: null,
			archiveName: null,
			meansType: null,
			medForm: null,
			archObjType: null,
			archObjNo: null,
			archObjName: null,
		};
		proxy.resetForm("ArchiveBoxinnerMoveRef");
	}

	/** 搜索按钮操作 */
	function handleQuery() {
		queryParams.value.pageNum = 1;
		getList();
	}

	/** 重置按钮操作 */
	function resetQuery() {
		proxy.resetForm("queryRef");
		handleQuery();
	}

	// 多选框选中数据
	function handleSelectionChange(selection) {
		ids.value = selection.map(item => item.id);
		single.value = selection.length != 1;
		multiple.value = !selection.length;
	}

	/** 新增按钮操作 */
	function handleAdd() {
		reset();
		open.value = true;
		title.value = "添加盒间移位详情";
	}

	/** 修改按钮操作 */
	function handleUpdate(row) {
		reset();
		const id = row.id || ids.value
		getArchiveBoxinnerMove(id).then(response => {
			form.value = response.data;
			open.value = true;
			title.value = "修改盒间移位详情";
		});
	}

	/** 提交按钮 */
	function submitForm() {
		proxy.$refs["ArchiveBoxinnerMoveRef"].validate(valid => {
			if (valid) {
				if (form.value.id != null) {
					updateArchiveBoxinnerMove(form.value).then(response => {
						proxy.$modal.msgSuccess("修改成功");
						open.value = false;
						getList();
					});
				} else {
					addArchiveBoxinnerMove(form.value).then(response => {
						proxy.$modal.msgSuccess("新增成功");
						open.value = false;
						getList();
					});
				}
			}
		});
	}

	/** 删除按钮操作 */
	function handleDelete(row) {
		const ids = row.id || ids.value;
		proxy.$modal.confirm('是否确认删除盒间移位详情编号为"' + ids + '"的数据项？').then(function() {
			return delArchiveBoxinnerMove(ids);
		}).then(() => {
			getList();
			proxy.$modal.msgSuccess("删除成功");
		}).catch(() => {});
	}

	/** 导出按钮操作 */
	function handleExport() {
		proxy.download('archive/ArchiveBoxinnerMove/export', {
			...queryParams.value
		}, `盒间档案移位详情记录_${new Date().getTime()}.xlsx`)
	}

	getList();
</script>
